//
//  SelectDateView.m
//  Traveling
//
//  Created by 尹桥印 on 15/6/22.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "SelectDateView.h"
@interface SelectDateView()


@property (nonatomic, copy) void(^result)(NSString *dateStr,NSDate *date);
@end
@implementation SelectDateView



+(instancetype)dateViewWithResult:(void(^)(NSString *dateStr,NSDate *date))result{
    SelectDateView *selectDateView= [[[NSBundle mainBundle] loadNibNamed:@"SelectDateView" owner:nil options:nil] lastObject];
    selectDateView.result = result;
    return selectDateView;
}
+(instancetype)dateViewWithResult:(void(^)(NSString *dateStr,NSDate *date))result currentDate:(NSDate *)currentDate minDate:(NSDate *)minDate{
    SelectDateView *selectDateView= [[[NSBundle mainBundle] loadNibNamed:@"SelectDateView" owner:nil options:nil] lastObject];
    selectDateView.datePickerView.date = currentDate;
    selectDateView.datePickerView.minimumDate = minDate;
    selectDateView.result = result;
    return selectDateView;
}

- (IBAction)enterBtnClick:(UIButton *)sender {
    if (self.result) {
        NSDate *date = self.datePickerView.date;
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        formatter.dateFormat = @"yyyy-MM-dd";
        self.result([formatter stringFromDate:date],date);
    }
}

@end
